<script>
function ajaxPage(url,currentPage,obj){
  var target_id=jQuery(obj).parent().attr("target_id");	
  jQuery.post(url,{"currentPage":currentPage,"target_id":target_id,"goods_type":"combin"},
			      function(data){
							  jQuery("#"+target_id).empty().append(data);
							 },"text");
}
function set_combin_goods(obj){
  var goods_name= jQuery(obj).attr("goods_name");
  var goods_img=jQuery(obj).attr("goods_img");
  var goods_current_price=jQuery(obj).attr("goods_current_price");
  var goods_id=jQuery(obj).attr("goods_id");
  var main_goods_id=jQuery("#combin_main_goods_id").val();
  if(goods_id==main_goods_id){
     alert("该商品已经为主商品，不能添加到组合");
	 return;
  }
  var combin=false;
  jQuery("img[combin_goods_img=true]").each(function(){
     var combin_goods_id=jQuery(this).attr("goods_id");
	 if(combin_goods_id==goods_id){
         combin=true;
	 }
  });
  if(combin){
   	 alert("组合中已经存在该商品");
	 return;
  }
  jQuery("img[combin_goods_img=false]").first().attr("src",goods_img);
  jQuery("img[combin_goods_img=false]").first().parent().parent().find("i").html(goods_name);
  jQuery("img[combin_goods_img=false]").first().attr("goods_current_price",goods_current_price);
  jQuery("img[combin_goods_img=false]").first().attr("goods_id",goods_id);
  jQuery("img[combin_goods_img=false]").first().attr("combin_goods_img","true");
  jQuery("label[for=combin_goods_ids]").remove();
   var total_price=parseFloat(jQuery("#combin_main_goods_img").attr("goods_current_price"));
	jQuery("img[combin_goods_img=true]").each(function(){
	   var combin_goods_price=jQuery(this).attr("goods_current_price");
	   if(combin_goods_price!=undefined){
	     total_price=total_price+parseFloat(combin_goods_price);
	   }
	});
  jQuery("#combin_goods_price").html(total_price);
}
</script>
<div class="main_body">
  <ul>
  #foreach($obj in $objs)
      #if($!obj.goods_main_photo)               
        #set($img="$!imageWebServer/$!{obj.goods_main_photo.path}/$!{obj.goods_main_photo.name}_small.$!{obj.goods_main_photo.ext}")
      #else
        #set($img="$!imageWebServer/$!{config.goodsImage.path}/$!{config.goodsImage.name}")
      #end
      <li class="item"> <span><a href="$!webPath/goods_$!{obj.id}.htm" target="_blank"><img src="$!img" width="110" height="110" /></a></span> <i><a href="$!webPath/goods_$!{obj.id}.htm" target="_blank">$!CommUtil.substring("$!obj.goods_name",8)</a></i>
      <div class="ogal_price"><b>价格：</b>¥$!{obj.goods_current_price}
      </div>
      <div class="add_gp">
         <input type="button" value="添加到组合" goods_img="$!img" goods_name='$!CommUtil.substring("$!obj.goods_name",8)' goods_current_price="$!obj.goods_current_price" goods_id="$!obj.id" onclick="set_combin_goods(this);" class="add_ip" />
      </div>
    </li>
    #end
  </ul>
  <div class="Day_fy" target_id="$!target_id">$!gotoPageAjaxHTML</div>
</div>
